//
//  CreateJobReviewOwnerInfoView.swift
//  GreenDeal
//
//  Created by Moennig Q on 2023/3/7.
//

import UIKit

class CreateJobReviewIndividualOwnerInfoView: View {
    let propertyTypeText = CreateJobReviewContentLabel()
    let ownerTypeText = CreateJobReviewContentLabel()
    let nameText = CreateJobReviewContentLabel()
    let mobileText = CreateJobReviewContentLabel()
    let emailText = CreateJobReviewContentLabel()
    let gstText = CreateJobReviewContentLabel()
    //
    override func setUpView() {
        //property type
        let propertyTypeTitle = CreateJobReviewTitleLabel(R.string.localizable.propertyType())
        self.addSubview(propertyTypeTitle)
        propertyTypeTitle.snp.makeConstraints { make in
            make.top.left.equalTo(16)
            make.size.greaterThanOrEqualTo(0)
        }
        self.addSubview(propertyTypeText)
        propertyTypeText.snp.makeConstraints { make in
            make.top.equalTo(propertyTypeTitle)
            make.right.equalTo(-16)
            make.size.greaterThanOrEqualTo(0)
        }
        //owner type
        let ownerTypeTitle = CreateJobReviewTitleLabel(R.string.localizable.ownerType())
        self.addSubview(ownerTypeTitle)
        ownerTypeTitle.snp.makeConstraints { make in
            make.top.equalTo(propertyTypeTitle.snp.bottom).offset(CREATEJOB_REVIEW_INTERNAL)
            make.left.equalTo(propertyTypeTitle)
            make.size.greaterThanOrEqualTo(0)
        }
        self.addSubview(ownerTypeText)
        ownerTypeText.snp.makeConstraints { make in
            make.top.equalTo(ownerTypeTitle)
            make.right.equalTo(propertyTypeText)
            make.size.greaterThanOrEqualTo(0)
        }
        //name
        let nameTitle = CreateJobReviewTitleLabel(R.string.localizable.name())
        self.addSubview(nameTitle)
        nameTitle.snp.makeConstraints { make in
            make.top.equalTo(ownerTypeTitle.snp.bottom).offset(CREATEJOB_REVIEW_INTERNAL)
            make.left.equalTo(propertyTypeTitle)
            make.size.greaterThanOrEqualTo(0)
        }
        self.addSubview(nameText)
        nameText.snp.makeConstraints { make in
            make.top.equalTo(nameTitle)
            make.right.equalTo(propertyTypeText)
            make.size.greaterThanOrEqualTo(0)
        }
        //mobie
        let mobieTitle = CreateJobReviewTitleLabel(R.string.localizable.mobile())
        self.addSubview(mobieTitle)
        mobieTitle.snp.makeConstraints { make in
            make.top.equalTo(nameTitle.snp.bottom).offset(CREATEJOB_REVIEW_INTERNAL)
            make.left.equalTo(propertyTypeTitle)
            make.size.greaterThanOrEqualTo(0)
        }
        self.addSubview(mobileText)
        mobileText.snp.makeConstraints { make in
            make.top.equalTo(mobieTitle)
            make.right.equalTo(propertyTypeText)
            make.size.greaterThanOrEqualTo(0)
        }
        //email
        let emailTitle = CreateJobReviewTitleLabel(R.string.localizable.email())
        self.addSubview(emailTitle)
        emailTitle.snp.makeConstraints { make in
            make.top.equalTo(mobieTitle.snp.bottom).offset(CREATEJOB_REVIEW_INTERNAL)
            make.left.equalTo(propertyTypeTitle)
            make.size.greaterThanOrEqualTo(0)
        }
        self.addSubview(emailText)
        emailText.snp.makeConstraints { make in
            make.top.equalTo(emailTitle)
            make.right.equalTo(propertyTypeText)
            make.size.greaterThanOrEqualTo(0)
            
        }
        //gst
        let gstTitle = CreateJobReviewTitleLabel(R.string.localizable.gsT())
        self.addSubview(gstTitle)
        gstTitle.snp.makeConstraints { make in
            make.top.equalTo(emailTitle.snp.bottom).offset(CREATEJOB_REVIEW_INTERNAL)
            make.left.equalTo(propertyTypeTitle)
            make.size.greaterThanOrEqualTo(0)
            make.bottom.equalTo(-16)
        }
        self.addSubview(gstText)
        gstText.snp.makeConstraints { make in
            make.top.equalTo(gstTitle)
            make.right.equalTo(propertyTypeText)
            make.size.greaterThanOrEqualTo(0)
            
        }
    }
    func setData(){
        self.propertyTypeText.text = CreateJobModelHelper.shared.createJobViewModel.propertyOwner.property_type.rawValue
        self.ownerTypeText.text = CreateJobModelHelper.shared.createJobViewModel.propertyOwner.owner_type.rawValue
        self.nameText.text = CreateJobModelHelper.shared.createJobViewModel.propertyOwner.full_name
        self.mobileText.text = CreateJobModelHelper.shared.createJobViewModel.propertyOwner.mobile
        self.emailText.text = CreateJobModelHelper.shared.createJobViewModel.propertyOwner.email
        self.gstText.text = (CreateJobModelHelper.shared.createJobViewModel.propertyOwner.gst ? "Yes" : "No")
    }
}
